package genes;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class AmbiguityCodes {

	private List<String> ambiguityCodes;
	
	public AmbiguityCodes(){
		this.setAmbiguityCodes();
	}

	private void setAmbiguityCodes(){
		this.ambiguityCodes= new ArrayList<String>();
		this.ambiguityCodes.add("R");
        this.ambiguityCodes.add("M");
		this.ambiguityCodes.add("W");
		this.ambiguityCodes.add("Y");
		this.ambiguityCodes.add("S");
		this.ambiguityCodes.add("K");
		this.ambiguityCodes.add("V");
		this.ambiguityCodes.add("H");
		this.ambiguityCodes.add("D");
		this.ambiguityCodes.add("B");
		this.ambiguityCodes.add("N");
		this.ambiguityCodes.add("I");
	}

	public List<String> getAmbiguityCodes() {
		return ambiguityCodes;
	}
	
	public boolean isAmbiguityCode(char x){
		Iterator<String> iter = this.ambiguityCodes.iterator();
		boolean result = false;
		while(iter.hasNext()){
			if(iter.next().charAt(0)==x){
				result=true;
				break;
			} 
		}
		return result;
	}

	public boolean containsAmbiguity(String x) {
		return this.isAmbiguityCode(x.charAt(0))|| this.isAmbiguityCode(x.charAt(1))||
		this.isAmbiguityCode(x.charAt(2));
	}
	
}
